﻿namespace Devonline.Entity;

/// <summary>
/// 货品, 字符串表达式的默认实现
/// </summary>
[DisplayName("货品")]
public class ProductPackageViewModel : ProductPackageViewModel<string>, IViewModel, IEntitySet
{
    /// <summary>
    /// 货品
    /// </summary>
    public virtual ProductViewModel? Product { get; set; }
    /// <summary>
    /// 包装
    /// </summary>
    public virtual PackageViewModel? Package { get; set; }
}

/// <summary>
/// 货品包装
/// </summary>
/// <typeparam name="TKey"></typeparam>
[DisplayName("货品包装")]
public abstract class ProductPackageViewModel<TKey> : ViewModel<TKey>, IViewModel<TKey>, IEntitySet<TKey> where TKey : IConvertible
{
    /// <summary>
    /// 货品编号
    /// </summary>
    [DisplayName("货品编号"), Required, MaxLength(36), Excel]
    public virtual TKey ProductId { get; set; } = default!;
    /// <summary>
    /// 包装编号
    /// </summary>
    [DisplayName("包装编号"), Required, MaxLength(36), Excel]
    public virtual TKey PackageId { get; set; } = default!;

    /// <summary>
    /// 包装数量, 装箱数量, 单箱货品数量, 包装后的单箱标称量, PCS/CTN 装箱率, 每箱数量
    /// </summary>
    [DisplayName("数量"), Excel]
    public virtual decimal Count { get; set; }
    /// <summary>
    /// 体积, 装箱体积, 单箱体积, 包装后的单箱标称量, CBM/CTN 单箱体积, 尺寸单位 cm, 体积取整数
    /// </summary>
    [DisplayName("体积"), Excel]
    public virtual decimal Volume { get; set; }
    /// <summary>
    /// 重量, 装箱重量, 单箱重量, 包装后的单箱标称量, G.W./CTN 单箱毛重
    /// </summary>
    [DisplayName("重量"), Excel]
    public virtual decimal Weight { get; set; }

    /// <summary>
    /// 重量体积比, 用于计算装柜时的总重和总体积参考
    /// </summary>
    [DisplayName("重量体积比"), Excel]
    public virtual decimal WeightVolumeRatio => Weight / Volume;
}
